from selenium.webdriver.common.by import By
from common.Utils import BlogDirver


class BlongList:
    url = "http://8.137.19.140:9090/blog_list.html"
    driver = BlogDirver.driver
    driver.get(url)

    def ListTest(self):
        # 个人信息板块
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > img")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > a")
        # 菜单栏
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(4)")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(5)")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(6)")
        # 博客列表模块
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > a").click()

        # 获取当前页面句柄
        curWindows = self.driver.current_window_handle
        # 获取所有页面句柄
        allWindows = self.driver.window_handles
        for windows in allWindows:
            if windows != curWindows:
                self.driver.switch_to.window(windows)
        title = self.driver.title

        assert title == "博客详情页"
        BlogDirver.GetScreenShot()